﻿using System.Collections.ObjectModel;
using System;
using System.ComponentModel;
using System.Linq;
using System.ServiceModel.DomainServices.Client;

namespace MedLink2011.Web.Models
{
    /// <summary>
    /// Extensions to provide client side custom validation, Business Logic and data binding 
    /// </summary>
    public partial class Appointment
    {
        public string IntKey3
        {
            get
            {
                return Validity_Status + Urgency;
            }
        }

        partial void OnUrgencyChanged()
        {
            RaisePropertyChanged("IntKey3");
        }

        partial void OnValidity_StatusChanged()
        {
            RaisePropertyChanged("IntKey3");
        }

        // Vertical Formula
        public double TotalPrice
        {
            get { return GetTotalPrice(); }
        }

        // this is the one that when changes makes the calculation to happen because it Raise the Property change
        // on price change for exmple
        
        partial void OnCommentsChanged()
        {
            RaisePropertyChanged("TotalPrice");
        }
        private ObservableCollection<Appointment> _appointment;
        public double GetTotalPrice()
        {
            double valueOut = 0;
            foreach (Appointment i in _appointment.Where(ii => ii.Apointment_id == 1)) // for Customer Number 44 for example
            {
                valueOut = valueOut + i.Apointment_id; // you need to change this for let’s say plus Price
            }
            return Math.Round(valueOut, 2);
        }
    }
}

